<template>
  <div style="font-size: 12px;display: flex;">
    <div style="flex: 1; font-size: 18px;">
      <span :class="collapseBtnClass" style="cursor: pointer" @click="collapse"></span>
    </div>
    <el-dropdown style="display: inline-block;float: right">
      <div style="display: inline-block">
        <img src = "../assets/logo.png" alt = "" style="width: 30px; border-radius: 50%; position: relative; top: 10px; right: 5px">
        <span style="color: rgb(48, 65, 86);">{{ user.username }}<i class="el-icon-arrow-down" style="margin-left: 15px;flex: 2"></i></span>
      </div>
      <el-dropdown-menu slot="dropdown" style="width: 100px; text-align: center">
        <el-dropdown-item><span @click="mine">个人信息</span></el-dropdown-item>
        <el-dropdown-item><span @click="logout()">退出</span></el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  name: "Header",
  data() {
    return {
      user: localStorage.getItem('user')? JSON.parse(localStorage.getItem('user')): {}
    }
  },
  props:{
    collapseBtnClass:String,
    collapse:Function
  },
  methods: {
    logout() {
      this.$router.push('/login')
      localStorage.removeItem("user")
      this.$message.success("已退出")
    },
    mine() {
      this.$router.push('/mine')
    }
  }
}
</script>

<style scoped>

</style>
